package com.javacommunity.model.entity;

// Generated Nov 25, 2014 11:55:44 PM by Hibernate Tools 3.4.0.CR1
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * UserAnswer generated by hbm2java
 */
@Entity
@Table(name = "user_answer", catalog = "db_javadanang", uniqueConstraints = @UniqueConstraint(columnNames = {
    "userId", "answerId"}))
public class UserAnswer implements java.io.Serializable {

    private Integer userAnswerId;
    private Answer answer;
    private User user;
    private boolean vote;

    public UserAnswer() {
    }

    public UserAnswer(Answer answer, User user, boolean vote) {
        this.answer = answer;
        this.user = user;
        this.vote = vote;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "user_answerId", unique = true, nullable = false)
    public Integer getUserAnswerId() {
        return this.userAnswerId;
    }

    public void setUserAnswerId(Integer userAnswerId) {
        this.userAnswerId = userAnswerId;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "answerId", nullable = false)
    public Answer getAnswer() {
        return this.answer;
    }

    public void setAnswer(Answer answer) {
        this.answer = answer;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "userId", nullable = false)
    public User getUser() {
        return this.user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @Column(name = "vote", nullable = false)
    public boolean isVote() {
        return this.vote;
    }

    public void setVote(boolean vote) {
        this.vote = vote;
    }

}
